local zhenying = fk.CreateSkill{
  name = "wk_heg__zhenying",
}

Fk:loadTranslationTable{
  ["wk_heg__zhenying"] = "镇荧",
  [":wk_heg__zhenying"] = "每回合限一次，当你成为伤害牌的目标后，你可以弃置此牌使用者一张牌，若以此法弃置的牌为装备牌，你可以使用之或将手牌调整至装备区内牌数。",
  ["wk_heg__zhenying_use"] = "使用此牌",
  ["wk_heg__zhenying_adjust"] = "调整手牌",
}

zhenying:addEffect(fk.TargetConfirmed, {
  anim_type = "special",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and player == target and player:usedSkillTimes(zhenying.name, Player.HistoryTurn) == 0
     and data.card and data.card.is_damage_card and not data.from:isNude()
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local from = data.from
    local id = room:askToChooseCard(player,{
      target = from,
      flag = "he",
      skill_name = zhenying.name,
    })
    room:throwCard({id}, zhenying.name, from, player)
    local card = Fk:getCardById(id)
    if card.type == Card.TypeEquip then
      local choices = {"wk_heg__zhenying_use", "wk_heg__zhenying_adjust"}
      local choice = room:askToChoice(player, {choices = choices, skill_name = zhenying.name})
      if choice == "wk_heg__zhenying_use" then
        room:useCard({
          from = player,
          tos = nil,
          card = card,
        })
      else
        local dis = player:getHandcardNum() - #player:getCardIds("e")
        if dis > 0 then
          room:askToDiscard(player, {
            min_num = 1,
            max_num = 1,
            include_equip = false,
            skillName = zhenying.name,
            cancelable = false,
            skip = false,
        })
        elseif dis < 0 then
          player:drawCards(-dis, zhenying.name)
        end
      end
    end
  end
})

return zhenying